//
// Created by 李光辉 on 2020/12/31.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>

int main()
{
    int comm_sz;
    int my_rank;
    int source=0;
    int tag=1;
    double local_num;
    double  sum;

    MPI_Init(NULL,NULL);
    MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
    MPI_Comm_size(MPI_COMM_WORLD,&comm_sz);

    local_num = my_rank;
    printf("%d ----> %f \n",my_rank,local_num);

    MPI_Scan(&local_num,&sum,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);

    printf("%d ans----> %f\n",my_rank,sum);

    MPI_Finalize();
    return 0;
}